package com.woniuxy.controller.UserRelated;


import com.woniuxy.demo.Result;
import com.woniuxy.enums.CodeEnum;
import com.woniuxy.exception.PawnEmPowerException;
import com.woniuxy.param.UserRelatedParam.SaveRoleMenusParam;
import com.woniuxy.service.RoleMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zcx, ftl, gr, rhs
 * @since 2021-12-31
 */

@RestController
@RequestMapping("/role-menu")
@Api(tags = "菜单授权(角色和菜单)")
public class RoleMenuController {

    @Resource
    private RoleMenuService rms;

    /**
     * 修改授权状态
     * @param arm
     * @return
     */
    @ApiOperation("修改授权状态")
    @PostMapping("saveRoleMenus.do")
    public Result saveRoleMenus(@RequestBody SaveRoleMenusParam arm) {
        if (rms.saveRoleMenus(arm)) {
            return Result.newInstance().setCode(200).setMsg("授权成功");
        }
        throw new PawnEmPowerException(CodeEnum.EMPOWER_FAIL.getMessage(), CodeEnum.CODE_ERROR_PHONE.getCode());
    }


}

